﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using COM.OA.Entity;
using System.Collections.Generic;

public partial class wc_rlzy_dasc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        users loginuser =Session["loginuser"] as users;
        if (loginuser == null)
        {
            this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
        }
        else
        {
            int em_id = Int32.Parse(this.Request["eid"]);
            //查询 em_id 的 用户
            string where = "u_em_id=" + em_id;
            IList<users> uilist = usersBLL.Select(where);
            List<users> ulist = (List<users>)uilist;
            users u = new users();
            u = ulist[0];
            int uid = u.u_id;
            //根据 uid 删除 相关记录
            string attwhere = "att_u_id=" + uid;
            IList<attendance> attilist = attendanceBLL.Select(attwhere);
            List<attendance> attlist = (List<attendance>)attilist;
            attendance att = new attendance();
            att = attlist[0];
            int attid = att.att_id;
            attendanceBLL.Delete(attid);
            //删除用户
            usersBLL.Delete(uid);

            //删除档案
            int i = employeeBLL.Delete(em_id);
            if (i < 0)
            {
                this.Response.Write(string.Format(GetRedirect.REDIRECT, "rlzy_dagl.aspx"));
            }
            else
            {
                this.Response.Write(string.Format(GetRedirect.WINALERT, "删除失败!"));
                this.Response.Write(string.Format(GetRedirect.REDIRECT, "rlzy_dagl.aspx"));
            }
        }
        
    }
}
